# from time import sleep
# from selenium import webdriver

# driver = webdriver.Chrome()
# driver.implicitly_wait(5)
# driver.maximize_window()
# driver.get("https://mail.qq.com")
# # 切换至iframe
# driver.switch_to.frame("login_frame")
# driver.find_element("id", "u").send_keys("2349874")
# driver.find_element("id", "p").send_keys("zhao123456..")
# driver.find_element("id", "login_button").click()
# # 切出iframe
# driver.switch_to.default_content()
# sleep(3)
# # 点击已发送
# driver.find_element(
#     "xpath",
#     '//*[@id="mailMainApp"]/div[2]/div/div[2]/div[1]/ul/li[4]/a/span[1]'
# ).click()

# sleep(5)
# driver.quit()

from time import sleep
from selenium import webdriver
from selenium.webdriver import ActionChains
from selenium.webdriver import Keys

driver = webdriver.Chrome()
driver.implicitly_wait(5)
driver.maximize_window()
driver.get("https://www.qq.com")

login_ele = driver.find_element("css selector",
                                "#top-login > div.item.item-login.fl > a")
ActionChains(driver).move_to_element(login_ele).perform()
driver.find_element(
    "xpath", '//*[@id="top-login"]/div[3]/div[1]/div/p[1]/span').click()
login_ele.click()
driver.switch_to.frame("ptlogin_iframe")
driver.find_element("id", "switcher_plogin").click()
mail_account = driver.find_element("id", "u")
mail_account.send_keys(Keys.CONTROL, "a")
mail_account.send_keys(Keys.BACK_SPACE)
mail_account.send_keys("2349874")
mail_password = driver.find_element("id", "p")
mail_password.send_keys("zhao123456..")
driver.find_element("id", "login_button").click()
sleep(3)
driver.quit()